﻿<!--*********************************************************************

   Extended WPF Toolkit

   Copyright (C) 2010-2012 Xceed Software Inc.

   This program is provided to you under the terms of the Microsoft Public
   License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license 

   This program can be provided to you by Xceed Software Inc. under a
   proprietary commercial license agreement for use in non-Open Source
   projects. The commercial version of Extended WPF Toolkit also includes
   priority technical support, commercial updates, and many additional 
   useful WPF controls if you license Xceed Business Suite for WPF.

   Visit http://xceed.com and follow @datagrid on Twitter.

  ********************************************************************-->
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:Twi.COMMON.WPF.CtlExtended"
                    xmlns:themes="clr-namespace:Twi.COMMON.WPF.CtlExtended.Themes">

   <ResourceDictionary.MergedDictionaries>
      <ResourceDictionary Source="../../Themes/Generic/Glyphs.xaml" />
   </ResourceDictionary.MergedDictionaries>

   <!-- =============================================================================== -->
   <!-- ButtonSpinner                                                                   -->
   <!-- =============================================================================== -->

   <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />

   <Style TargetType="{x:Type local:ButtonSpinner}">
      <Setter Property="Background" Value="{DynamicResource {x:Static themes:ResourceKeys.ControlNormalBackgroundKey}}" />
      <Setter Property="BorderBrush" Value="{DynamicResource {x:Static themes:ResourceKeys.ControlNormalBorderKey}}" />
      <Setter Property="BorderThickness" Value="1" />
      <Setter Property="Focusable" Value="False" />
      <Setter Property="HorizontalContentAlignment" Value="Stretch" />
      <Setter Property="IsTabStop" Value="True" />
      <Setter Property="Padding" Value="2" />
      <Setter Property="VerticalContentAlignment" Value="Center" />
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="{x:Type local:ButtonSpinner}">
               <Grid SnapsToDevicePixels="True">
                  <Grid.ColumnDefinitions>
                     <ColumnDefinition Width="*" />
                     <ColumnDefinition Width="Auto" />
                  </Grid.ColumnDefinitions>

                  <Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Grid.ColumnSpan="2" />

                  <ContentPresenter Focusable="False" Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />

                  <Grid Grid.Column="1" Visibility="{TemplateBinding ShowButtonSpinner, Converter={StaticResource BooleanToVisibilityConverter}}" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}">
                     <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="*" />
                     </Grid.RowDefinitions>

                     <RepeatButton x:Name="PART_IncreaseButton"
                                   Style="{DynamicResource {x:Static themes:ResourceKeys.SpinnerButtonStyleKey}}"
                                   IsTabStop="{TemplateBinding IsTabStop}" ContentTemplate="{StaticResource IncreaseGlyphNormalKey}" />

                     <RepeatButton x:Name="PART_DecreaseButton"
                                   Grid.Row="1"
                                   Style="{DynamicResource {x:Static themes:ResourceKeys.SpinnerButtonStyleKey}}"
                                   IsTabStop="{TemplateBinding IsTabStop}" ContentTemplate="{StaticResource DecreaseGlyphNormalKey}" />

                  </Grid>
               </Grid>
               <ControlTemplate.Triggers>
                  <Trigger Property="IsEnabled" Value="False">
                     <Setter Property="Background" Value="{DynamicResource {x:Static themes:ResourceKeys.ControlDisabledBackgroundKey}}" />
                  </Trigger>
                  <Trigger SourceName="PART_IncreaseButton" Property="IsEnabled" Value="False">
                     <Setter TargetName="PART_IncreaseButton" Property="ContentTemplate" Value="{StaticResource IncreaseGlyphDisabledKey}" />
                  </Trigger>
                  <Trigger SourceName="PART_DecreaseButton" Property="IsEnabled" Value="False">
                     <Setter TargetName="PART_DecreaseButton" Property="ContentTemplate" Value="{StaticResource DecreaseGlyphDisabledKey}" />
                  </Trigger>
               </ControlTemplate.Triggers>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

</ResourceDictionary>